import { createSlice } from "@reduxjs/toolkit";
import store from 'store2'
const userSlice = createSlice({
    name: 'userslice',
    initialState: {
        loginStatus: store.get('loginStatus')===true,
        userInfo: store.get('userInfo') ?? {},
    },
    reducers: {
        setLoginStatus(state, action) {
            store.set('loginStatus', action.payload)
            state.loginStatus = store.get('loginStatus')
        },
        setUserInfo(state, action) {
            store.set('userInfo', action.payload)
            state.userInfo = store.get('userInfo')
        }
    }
})


export const { setUserInfo, setLoginStatus } = userSlice.actions;
export default userSlice.reducer;